package com.atguigu.spzx.manager.service.system.impl;

import com.atguigu.spzx.manager.mapper.SysUserRoleMapper;
import com.atguigu.spzx.manager.service.system.SysUserRoleService;
import com.atguigu.spzx.model.dto.system.AssginRoleDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Mahone
 */
@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {

    @Autowired
    private SysUserRoleMapper sysUserRoleMapper;
    @Override
    public void doAssginRoleIdToUser(AssginRoleDto assginRoleDto) {
        // 删除被分配用户的所有角色
        sysUserRoleMapper.deleteByUserId(assginRoleDto.getUserId());

        // 插入用户的角色数据
        sysUserRoleMapper.insertRoleIdByUserId(assginRoleDto.getRoleIdList(),assginRoleDto.getUserId());
    }
}
